package com.xiang.consumer;

import com.xiang.config.RabbitMqSimpleConfig;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.stereotype.Component;

/**
 * 工作队列（能者多劳）
 *
 * @author: xiangtianlei
 * @Date: 2022-9-8
 */
@Component
public class ConsumerSimpler {
    Logger log = LoggerFactory.getLogger(ConsumerSimpler.class);

    @RabbitListener(queues = RabbitMqSimpleConfig.SIMPLE_QUEUE)
    public void monitorSimpleQueue(String msg) {
        log.info("队列1接收到的消息为:" + msg);
    }

    @RabbitListener(queues = RabbitMqSimpleConfig.SIMPLE_QUEUE)
    public void listenerSimpleQueue(String msg) throws InterruptedException {
        log.info("队列2接收到的消息为：" + msg);
        // 睡眠500ms
        Thread.sleep(500);
    }

}
